<?php
namespace app\branch\model;

use think\Session;
use think\Model;
use think\Request;

/**
 * 分公司管理员管理
 */
class Caravancontrols extends model
{   
    use \app\common\traits\model\TraitModel;
    protected $table = 'caravan';
    protected $autoWriteTimestamp = 'timestamp';
    protected $createTime = 'created_at';
    protected $updateTime = 'updated_at';
    protected $type = [
            'piccaravan'=>'array',
            'caravancover'=>'array'
    ];
    /**
     * [getUserList 房车列表]
     * @param  [type] $querys [description]
     * @return [type]         [description]
     */
    public function getCaravanList($querys=[])
    {
        return $this->getInfoList($querys);
    }

    public function campcontrols()
    {
        return $this->belongsTo('Campcontrols','services');
    }
    public function usercontrols()
    {
        return $this->belongsTo('Usercontrols','user_id');
    }
    /**
     * [getUserIofo 房车详细信息]
     * @param  [type] $id [description]
     * @return [type]     [description]
     */
    public function getCaravanIofo($id)
    {
        return $this->where('id',$id)->find(); 
    }
    /**
     * [getStatus 状态转换]
     * @param  [type] $value [description]
     * @return [type]        [description]
     */
    public function getStatus($value)
    {
        $status = ['1'=>'已激活','0'=>'未激活'];
        return $status[$value];
    }
    /**
     * [getZiduan1 字段信息]
     * @return [type] [description]
     */
    public function getZiduan1()
    {
    $ziduan1=array(
    /////房车室内信息////////
    'wifi'=>['1'=>'有','2'=>'无'],
    'tv'=>['1'=>'有','2'=>'无'],
    'washer'=>['1'=>'有','2'=>'无'],
    'air_condition'=>['1'=>'有','2'=>'无'], 
    'the_shower'=>['1'=>'有','2'=>'无'],
    'extinguisher'=>['1'=>'有','2'=>'无'],
    'annunciator'=>['1'=>'有','2'=>'无'], 
    'monitored'=>['1'=>'有','2'=>'无'],
     );
         return $ziduan1;
         return $this->all();
     }
     //房车类型---房车品牌---房车国别---准驾类型
     /**
     * [getGrade 类型转换]
     * @param  [type] $id [description]
     * @return [type]     [description]
     */
    public function getCates($id)
    {
        $grades = db('car_cates')->column('name', 'id');
        if (array_key_exists($id, $grades)) {
           return $grades[$id];
        }
        return '无';
    }
    public function getBrands($id)
    {
        $grades = db('car_brands')->column('name', 'id');
        if (array_key_exists($id, $grades)) {
           return $grades[$id];
        }
        return '无';
    }
    public function getCountries($id)
    {
        $grades = db('car_countries')->column('name', 'id');
        if (array_key_exists($id, $grades)) {
           return $grades[$id];
        }
        return '无';
    }
    public function getDrtypes($id)
    {
        $grades = db('driver_types')->column('name', 'id');
        if (array_key_exists($id, $grades)) {
           return $grades[$id];
        }
        return '无';
    }
    /**
      * [getZiduan2 description]
      * @return [type] [description]
      */
    public function getZiduan3()
    {
        $ziduan3 = ['1'=>'自行式a','2'=>'自行式b','3'=>'自行式c'];
        return $ziduan3;
    }
    public function getZiduan3Name($value)
    {
        $status = ['1'=>'自行式a','2'=>'自行式b','3'=>'自行式c'];
        return $status[$value];
    }
    public function getRadioName($value)
    {
        if(empty($value)){
            return '无';
        }
        $status = ['1'=>'有','2'=>'无'];
        return $status[$value];
    }
}
